/**
 * 定义食物类Food
 */
class Food {
    //定义一个属性表示食物所对应的元素
    element: HTMLElement;

    constructor() {
        //获取页面中的food元素并将其赋值给element
        this.element = document.getElementById('food')!;
    }

    //获取x坐标方法
    get x() {
        return this.element.offsetLeft;
    }

    //获取y坐标方法
    get y() {
        return this.element.offsetTop;
    }

    change() {
        let top = Math.round(Math.random() * 29) * 10;
        let left = Math.round(Math.random() * 29) * 10;
        this.element.style.left = left + "px";
        this.element.style.top = top + "px";
    }



}

export default Food;

